<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 创建一个div节点
        let div = document.createElement("div");
        div.innerText = "默认内容"
        div.style.width = "200px";
        div.style.height = "200px";
        div.style.backgroundColor = "skyblue";

        // 获取页面body标签
        let body = document.querySelector("body");
        // 把div放入body的内部
        body.appendChild(div);

        // 创建一个a标签
        let a = document.createElement('a');
        a.href = "https://www.baidu.com";
        a.innerText = "百度一下";

        body.insertBefore(a, div);

        // 创建一个img标签
        let img = document.createElement('img');
        img.src = "https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/08/2024082903105725-1024x576.jpg"

        body.replaceChild(img, a);

    </script>
</body>

</html>